<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{mix('/css/web/user/matching.css')}}">
</head>
<body>
@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
        @include('web.layout.seller_nav')
        <div class="nav_right flr">
            <div class="base_content">
                <div class="line_title">项目配单处理</div>
                <div class="offer_main fl">
                    {{--交易状态; 1:等待付款，2: 付款完成 3: 已发货 4:确认完成 5:已取消--}}
                    <h2>
                        @if($data['orders']['order_status']==1)
                            已报价
                        @elseif($data['orders']['order_status']==2)
                            付款完成
                        @elseif($data['orders']['order_status']==3)
                            已发货
                        @elseif($data['orders']['order_status']==4)
                            确认完成
                        @elseif($data['orders']['order_status']==5)
                            已关闭
                        @endif
                    </h2>
                    <span class="fl">配单号：{{$data['item_code']}}</span>
                    <span class="fr">配单时间：{{$data['created_at']}}</span>
                </div>
                <div class="sales_info">
                    <div class="sales_info_left3 fl">
                        <h2>配单购买方信息</h2>
                        <span>昵称：{{$data['buyer_phone']}}（{{$data['buyer_contact']}}）</span>
                        <span>公司：{{$data['buyer_company']}}</span>
                    </div>
                    <div class="sales_info_left4 fl">
                        <h2>选择报价要素</h2>
                        <div class="price_box">
                            <span>价格包含：</span>
                            <label><input type="checkbox" name="price_contain[]" value="1" disabled="disabled" {{in_array(1,$data['quote_contain'])?'checked':''}}>票税</label>
                            <label><input type="checkbox" name="price_contain[]" value="2" disabled="disabled" {{in_array(2,$data['quote_contain'])?'checked':''}}>运费</label>
                            <label><input type="checkbox" name="price_contain[]" value="3" disabled="disabled" {{in_array(3,$data['quote_contain'])?'checked':''}}>施工安装</label>
                            <label><input type="checkbox" name="price_contain[]" value="4" disabled="disabled" {{in_array(4,$data['quote_contain'])?'checked':''}}>公报总价</label>
                        </div>
                        <span>交货时间：{{$data['quote_trade_time']}}   项目地点：{{$data['project_addr']}}</span>
                    </div>
                    <div class="sales_info_right2 fr">
                        <h2>配单销售方信息</h2>
                        <span>销售：{{$data['seller_phone']}}（{{$data['seller_contact']}}）</span>
                        <span>公司：{{$data['seller_company']}}</span>
                    </div>
                </div>
                {{--<div class="leaving_message fl">--}}
                    {{--<div class="leaving_message_left fl">买家留言：</div><div class="leaving_message_right fr">2017/08/02 13:48:49海康威视的同轴摄像你报的价格有点太高了</div>--}}
                {{--</div>--}}
                <!-- <div class="matching_h3 fl">配单详情</div> -->
                <div class="table">
                    <table>
                        <thead>
                        <tr>
                            <th width="40">序号</th>
                            <th width="140">品名</th>
                            <th width="140">品牌</th>
                            <th width="200">型号</th>
                            <th width="120">数量</th>
                            <th width="120">单价（元）</th>
                            <th width="120">合计（元）</th>
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($data['items_products'] as $k =>$v)
                            @if($v['type']==1)
                                <tr>
                                    <td>{{$v['id']}}</td>
                                    <td>{{$v['product_name']}}</td>
                                    <td>{{$v['brand']}}</td>
                                    <td>{{$v['model']}}</td>
                                    <td>{{$v['num']}}</td>
                                    <td><font>{{$v['price']}}</font></td>
                                    <td>{{$v['total_price']}}</td>
                                </tr>
                            @else
                                <tr>
                                    <td>{{$v['id']}}</td>
                                    <td>{{$v['product_name']}}</td>
                                    <td></td>
                                    <td></td>
                                    <td>{{$v['num']}}</td>
                                    <td><font>{{$v['price']}}</font></td>
                                    <td>{{$v['total_price']}}</td>
                                </tr>
                            @endif
                            @endforeach
                        </tbody>
                    </table>
                </div>
                <div class="price_calculate_main fr">
                    <span>商品总价：</span><div class="price_calculate_main_fr fl">￥<font class="gooos_total_price">{{$data['goods_total']}}</font></div>
                    <span>其它费用：</span><div class="price_calculate_main_fr fl">￥<font class="other_charges">{{$data['other_total']}}</font></div>
                    <span>总价：</span><div class="price_calculate_main_fr2 fl">￥<font class="total_price">{{$data['all_total']}}</font></div>
                </div>
            </div>
            @if($data['orders']['order_status']==1)
                <div class="generating_sheet_main fl">
                    <input type="button" class="tijiao" value="复制报价"  data-id="{{$data['id']}}">
                    <a class="close_btn fr" data-id="{{$data['id']}}">关闭配单</a>
                    {{--<a href="{{url('/member/seller/items')}}" class="order_back_btn">返回</a>--}}
                </div>
            @else
                <div class="order_back">
                   <a href="{{url('/member/seller/items')}}" class="order_back_btn">返回</a>
                </div>
            @endif

        </div>
    </div>
</div>
<div class="bg_h"></div>
@include('web.layout.footer')
<script type="text/javascript">

    $(function(){

        //关闭配单
        $(".close_btn").on('click', function(event) {
            var id = $(this).data('id');
            if(confirm("确认关闭配单吗？")) {
                $.ajax({
                    url: '/member/seller/items/' + id,
                    type: 'delete',
                    data: {},
                    dataType: 'json',
                    success: function (data) {
                        if(data.code==0){
                            layer.alert("关闭配单成功!", {icon: 1});
//                            location.reload();
                        }else{
                            layer.alert(data.message, {icon: 0});

                        }
                    }
                });
            }
        });

        //复制报价
        $(".tijiao").on('click', function(event) {
            if(confirm("复制配单后，此配单将关闭！确认操作吗？")){
                var id = $(this).data('id');
                $.ajax({
                    url: '/member/seller/items/item_clone/' + id,
                    type: 'get',
                    data: '',
                    dataType:'json',
                    success: function (data) {
                        layer.alert("复制报价成功!",{icon: 1});
                        window.location.href="/member/seller/items/create";
                    }
                });
            }

        });
    });

</script>
</body>
</html>